<?php
class Solution {
    /**
     * @param Integer[] $nums
     * @param Integer $target
     * @return Integer[]
     */
    function twoSum($nums, $target) {
        // 元素位置映射
        $num_pos_mapping = array();

        foreach ($nums as $num_index => $num_item) {
            $diff_value = $target - $num_item;

            if (isset($num_pos_mapping[$diff_value])) {
                return array($num_index, $num_pos_mapping[$diff_value]);
            }

            $num_pos_mapping[$num_item] = $num_index;
        }
    }
}
var_dump((new Solution())->twoSum(array(3, 3), 6));